Skip to main content

All Questions

2votes
2answers
276views

Is it ok to extend utilities?

Apache Commons has StringUtils. It's great, but I wish it had a shuffle() method or similar Is it ok to create my own StringUtils that extends Apache's StringUtils and adds the method (Apache's class ...
Sergey Zolotarev's user avatar
1vote
2answers
1kviews

Is it wrong to extend an inner static class in java? (Builder pattern)

I'm working on a java project for the university. The project is a card game in which you travel around a 2D map and fight against some enemies. My part consists of creating the deck and the cards. I ...
Matteo Paolucci's user avatar
0votes
1answer
2kviews

Java convention - Implementing two similar functions for two different objects

I have two classes, let's call them Foo and Bar. They both extend different classes (Foo extends X, Bar extends Y), which have some common ancestor "way up" the inheritance tree, something like this: ...
Mickey's user avatar
4votes
4answers
6kviews

How to avoid code duplication while extending two umodifiable classes

I already have this core class structure that can not be changed: class A { //some basic fields and methods } class B { //some another basic fields and methods } It is core classes and I'm ...
TEXHIK's user avatar
3votes
1answer
522views

Best design for classes that draw objects but do not inherit from JPanel

I'm doing the exercise 10.1, page 476 from the book Java: How To Program, Early Objects by Paul and Harvey Deitel (10th Edition). Modify the MyLine, MyOval and MyRectangle classes of GUI to create ...
Yos's user avatar
  • 167
1vote
1answer
93views

Object passed to super() referenced by subclass - Any Violations?

This is the code in question, comments point it out: class Actor extends Entity { private MutableVector2f position; private MutableIdentity identity; public Actor(MutableVector2f ...
Dioxin's user avatar
4votes
2answers
2kviews

Inheritance and factory together?

I have a hierarchical data model and am trying to implement their CRUD operations in my Web Application. Currently I have code inheritance for CRUD operations of my entities (resources) as follows: ...
Siddharth Trikha's user avatar
1vote
2answers
246views

Processing and sending processed data to super from child class constructor

I want to do some initialization in child class constructor and pass result to super(). But Java doesn't allow any processing in child class constructor before super() call. Whats a good way to ...
mzlo's user avatar
  • 141
0votes
5answers
1kviews

classes/inheritance, how do I handle special cases that require more change

I often find myself in this situation where I have a base class that does a lot of graphics. There are, for example, three strings that are positioned top, middle, bottom of an element. Like a scale ...
NikkyD's user avatar
2votes
3answers
158views

Refactor an old model of a LastUser Modification on every Object?

I have a software requirement, that needs to store the user that made the last modification to another object, for every object (assume that all objects are already mapped and into a BD). So we have ...
nicoLinjava's user avatar

close